# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  helper :all # include all helpers, all the time
  
  #$planeTaxHash = PlaneTax.findHash if $planeTaxHash==nil
  #$airportHash = Airport.findHash if $airportHash==nil
  
  def user_authorize
    if !session[:user_id]# or session[:client_ip] != request.env['HTTP_X_FORWARDED_FOR']
      reset_session
      #flash[:notice] = _('Please login or register first.')
      redirect_to(:controller => "index", :action => "index") and return
    end
    if Time.now.strftime("%m")=='11'
      redirect_to(:controller => "index", :action => "index") and return
    end
  end
  
  def web_user_authorize
    if !session[:web_user_id]# or session[:client_ip] != request.env['HTTP_X_FORWARDED_FOR']
      reset_session
      #flash[:notice] = _('Please login or register first.')
      redirect_to(:controller => "index", :action => "happy") and return
    end
  end
  
  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => 'ec78ab8f7fcc8a1b97c5d721e42b114c'
  
  
  skip_before_filter :verify_authenticity_token
  
  
  self.allow_forgery_protection = false
end
